namespace EyeOpen.Warehouse.Mvc.TestMvc.Tests.Controllers
{
	using System;
	using System.Linq;

	using Domain;

	using EyeOpen.Warehouse.Mvc.ViewModel.Controllers;
	using EyeOpen.Warehouse.Mvc.ViewModel.Models;

	using Microsoft.VisualStudio.TestTools.UnitTesting;

	[TestClass]
	public class CustomerControllerTest
	{
		[TestMethod]
		public void SaveCustomer()
		{
			var fakeWarehouseContext = new FakeWarehouseContext();

			var controller = new CustomerController(fakeWarehouseContext);

			Assert.AreEqual(0, fakeWarehouseContext.CustomerRepository.Count());

			controller.Save(new CustomerModel { Name = "Steve" });

			var customer = fakeWarehouseContext.CustomerRepository.Single();

			Assert.AreEqual("Steve", customer.Name);
		}

		[TestMethod]
		public void DeleteAllCustomer()
		{
			var fakeWarehouseContext = new FakeWarehouseContext();

			var controller = new CustomerController(fakeWarehouseContext);

			fakeWarehouseContext.CustomerRepository.Add(new Customer { Id = Guid.NewGuid(), Name = "Steve" });
			Assert.AreEqual(1, fakeWarehouseContext.CustomerRepository.Count());

			controller.DeleteAll();

			Assert.AreEqual(0, fakeWarehouseContext.CustomerRepository.Count());
		}
	}
}